<template>
  <div class="task-del">
    <div class="shade"></div>
    <div class="popup">
      <div class="title justify-content-between">
        <span class="fs28 colorFFF">任务删除</span>
        <img src="../assets/images/icon-close.png" @click="cancel" />
      </div>
      <div class="txt">
        <img src="../assets/images/icon-del-big.png" />是否确认删除此项任务？
      </div>
      <div class="btns justify-content-center">
        <div class="btn sure" v-loading="loading" @click="del">确认</div>
        <div class="btn cancel" @click="cancel">取消</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "TaskDel",
  props: {
    id: Number,
  },
  data() {
    return {
      loading: false, //加载中
    };
  },
  methods: {
    /**
     * 关闭弹窗
     * @param {Number} refresh - 是否刷新 1是
     */
    cancel(refresh) {
      this.$emit("cancel", refresh);
    },
    // 删除
    del() {
      let _this = this;
      let params = {
        id: _this.id,
      };
      _this.loading = true;
      _this.axios
        .taskDel(params)
        .then((res) => {
          console.log(res);
          if (res.code == 200) {
            _this.$message({
              message: res.msg,
              type: "success",
            });
            _this.cancel(1);
          }
          _this.loading = false;
        })
        .catch(function (error) {
          _this.loading = false;
          _this.$message.error(error.msg);
        });
    },
  },
};
</script>

<style scoped lang='less'>
@import url("../assets/css/public.css");
.task-del {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  .shade {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
  }
  .popup {
    width: 5.07rem;
    height: 3.5rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    box-shadow: 0 0.05rem 0.15rem 0 rgba(0, 21, 54, 0.25);
    .title {
      width: 100%;
      height: 0.58rem;
      background-color: #285fe3;
      padding: 0 0.2rem 0 0.25rem;
      img {
        width: 0.23rem;
        height: 0.23rem;
        cursor: pointer;
      }
    }
    .txt {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-top: 0.76rem;
      font-size: 0.24rem;
      color: #161d2e;
      img {
        margin-right: 0.12rem;
        width: 0.53rem;
        height: 0.59rem;
      }
    }
    .btns {
      width: 100%;
      margin-top: 0.84rem;
      .btn {
        width: 1.3rem;
        height: 0.4rem;
        margin-left: 0.52rem;
        line-height: 0.4rem;
        text-align: center;
        border-radius: 0.03rem;
        font-size: 0.22rem;
        cursor: pointer;
      }
      .btn.sure {
        background: linear-gradient(0deg, #00a366 0%, #00c37a 100%);
        color: #fff;
      }
      .btn.cancel {
        border: 1px solid #316eff;
        background: linear-gradient(0deg, #d9dde8 0%, #ffffff 100%);
        color: #505971;
      }
      .btn:first-child {
        margin-left: 0;
      }
    }
  }
}
</style>